package com.deluxelx.soul.inn.common.constant;

import cn.hutool.core.util.StrUtil;
import com.deluxelx.soul.inn.common.param.CollectedParam;

import static com.deluxelx.soul.inn.common.constant.UserConstant.USER_CACHE_KEY_PREFIX;

/**
 * 文章相关常数
 *
 * @author liaozihao
 * @date 2024-04-15 11:48
 */
public class ArticleConstant {

    public static final String ARTICLE_CACHE_KEY_PREFIX = "article_";

    public static final Integer ARTICLE_CACHE_EXPIRE_TIME = 60 * 60 * 24 * 7;

    public static final String ARTICLE_FOLLOW_KEY = "followArticle";

    public static final String ARTICLE_READ_KEY = "readArticle";

    public static final String articleTaskPattern1 = "user_*:article_*";

    public static final String articleTaskPattern2 = "followArticle:*";

    public static final String articleTaskPattern3 = "readArticle:*";

    public static String buildFollowArticleKey(CollectedParam param) {
        return USER_CACHE_KEY_PREFIX + param.getUserId() + StrUtil.COLON + ARTICLE_CACHE_KEY_PREFIX + param.getArticleId();
    }

    public static String buildFollowArticleKey(String articleId) {
        return ARTICLE_FOLLOW_KEY + StrUtil.COLON + articleId;
    }

    public static String buildReadArticleKey(String articleId) {
        return ARTICLE_READ_KEY + StrUtil.COLON + articleId;
    }

}
